# -*- coding: utf-8 -*-
from Page.sessionPage import sessionPage
from Page.noscanningPage import noscanningPage
from Page.chargemanagerPage import chargemanagerPage
import time
import os
from selenium.webdriver.support.ui import Select
from selenium.webdriver import ActionChains
class chargemanager():
    def __init__(self,driver):
        self.driver=driver
        self.sessionPage = sessionPage(self.driver)
        self.noscanningPage = noscanningPage(self.driver)
        self.chargemanagerPage=chargemanagerPage(self.driver)
    # 点击团险业务
    def grouplife(self):
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("head")
        time.sleep(1)
        self.sessionPage.btnGroup().click()
        time.sleep(1)

    # 点击收付费管理
    def acceptpayment(self):
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraMenu")
        time.sleep(1)
        self.sessionPage.btnAcceptPayment().click()
        time.sleep(1)
    def chargeManager(self,FeeCustAccName,DuePayGrpContNo):
        # 点击收费管理
        self.chargemanagerPage.btnChargeManager().click()
        time.sleep(1)
        # 点击保费匹配
        self.chargemanagerPage.btnPremiummatch().click()
        time.sleep(1)
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('fraInterface')
        time.sleep(1)
        # 查询
        self.chargemanagerPage.inpFeeCustAccName().send_keys(FeeCustAccName)
        time.sleep(1)
        self.chargemanagerPage.btnQuery().click()
        time.sleep(1)
        # 选择数据
        self.chargemanagerPage.chbFinDataGridChk().click()
        time.sleep(1)
        # 点击选择
        self.chargemanagerPage.btnChoose().click()
        time.sleep(1)
        # 勾选数据
        # self.chargemanagerPage.chbChoosedDataGridChk().click()
        # time.sleep(1)
        self.chargemanagerPage.inpDuePayGrpContNo().send_keys(DuePayGrpContNo)
        time.sleep(1)
        self.chargemanagerPage.btnQuery2().click()
        time.sleep(1)
        self.chargemanagerPage.radBusinessDataGridSel().click()
        time.sleep(1)
        self.chargemanagerPage.btnPremMatchButton().click()
        time.sleep(1)
        window1 = self.driver.window_handles
        self.driver.switch_to.window(window1[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)
        window2 = self.driver.window_handles
        self.driver.switch_to.window(window2[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('fraInterface')
        time.sleep(1)
        # radio = self.chargemanagerPage.radMatchingConfirmGridSel()
        # number = len(radio)
        # for j in range(number):
        #     radio[j].click()
        self.chargemanagerPage.radMatchingConfirmGridSel().click()
        time.sleep(1)
        self.chargemanagerPage.btnConfirmButton().click()
        time.sleep(1)
        window3 = self.driver.window_handles
        self.driver.switch_to.window(window3[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)
        window4 = self.driver.window_handles
        self.driver.switch_to.window(window4[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('fraInterface')
        time.sleep(1)
        # 保费确认
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('fraMenu')
        time.sleep(1)
        self.chargemanagerPage.btnConfirmButton().click()
        time.sleep(1)
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('fraInterface')
        time.sleep(1)
        self.chargemanagerPage.btnConfirm().click()
        time.sleep(1)
        self.chargemanagerPage.btnQuery3().click()
        time.sleep(1)
        # radio1=self.chargemanagerPage.btnMatchInfoGridSel()
        # number1 = len(radio)
        # for j in range(number1):
        #     radio1[j].click()
        self.chargemanagerPage.btnMatchInfoGridSel().click()
        time.sleep(1)
        ActionChains(self.driver).double_click(self.chargemanagerPage.btnConfirmConclusion()).perform()
        time.sleep(1)
        Select(self.chargemanagerPage.secConfirmConclusion()).select_by_visible_text('00-通过')
        time.sleep(1)
        self.chargemanagerPage.inpConfirmDesc().send_keys('i do')
        time.sleep(1)
        self.chargemanagerPage.btnMatchConfirmButton().click()
        time.sleep(1)
        window5 = self.driver.window_handles
        self.driver.switch_to.window(window5[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)











